// this comment is from  the copy in the trunk
#include <iostream>
using namespace std;

class workingHours 
{
   
public:
    workingHours(int H, int M, int S);     
    workingHours(){};
    workingHours operator + (workingHours &day);

    struct foo
    {
        foo(){};  // this is for the object that will accumulate the addition of obj of day1 + obj of day2. Creating it doesnt need any input. d3 could be created without (0,0,0) arguments
        foo(int theHours, int theMinutes, int theSeconds):
        HoursVal(theHours),
        MinutesVal(theMinutes),
        SecondsVal(theSeconds){}
        
        int HoursVal;
        int MinutesVal;
        int SecondsVal;
    };

    struct foototal
    {
        foototal():
        sumDays(0),
        sumHours(0),
        sumMinutes(0),
        sumSeconds(0){}
        int sumDays;
        int sumHours;
        int sumMinutes;
        int sumSeconds;
    };
    
    foototal totalTime();
    foototal adjustedTime;
    foo  getTime(); 

private:
    struct foo timeStruct;
};

//setter
workingHours::workingHours(int H, int M, int S):timeStruct(H,M,S){}

//getter
workingHours::foo workingHours::getTime()
{
   return workingHours::foo(timeStruct.HoursVal, timeStruct.MinutesVal, timeStruct.SecondsVal);
}

workingHours::foototal workingHours::totalTime()
{
    int total = timeStruct.HoursVal*3600 + timeStruct.MinutesVal*60 + timeStruct.SecondsVal;
    int d, h, m, s;
    d = h = m = s = 0;
    
    if (total > 86400 )
    {
      while (total > 86400 )
        {
        d++;
        total -= 86400;
        }
    }

    if (total < 86400 && total > 3600  )
    {
       while (total > 3600)
       {
        h++;
        total -= 3600;
       }    
    }
  
    if (total < 3600 && total > 60  )
    {
      while (total > 60)
      {
       m++;
       total -= 60;
      }
    }
   s = total;
   workingHours::adjustedTime.sumSeconds = s;
   workingHours::adjustedTime.sumMinutes = m;
   workingHours::adjustedTime.sumHours = h;
   workingHours::adjustedTime.sumDays = d;
    
   return workingHours::foototal(workingHours::adjustedTime);



}
     

workingHours workingHours::operator + (workingHours &day1)
{
   return workingHours(this->timeStruct.HoursVal += day1.getTime().HoursVal, this->timeStruct.MinutesVal += day1.getTime().MinutesVal, this->timeStruct.SecondsVal += day1.getTime().SecondsVal);
}

int main()
{
int x1, y1, z1, x2, y2, z2;
 x1 = y1 = z1 = x2 = y2 = z2 = 0;
cout << "Enter Day1: HH:MM:SS " << endl;
cin >> x1 >> y1 >> z1;

cout << "Enter Day2: HH:MM:SS " << endl;
cin >> x2 >> y2 >> z2;

workingHours d1(x1,y1,z1);
workingHours d2(x2,y2,z2);
workingHours d3(0,0,0);
    
d3 = d1 + d2;

cout << "SumHours:   " << d3.getTime().HoursVal   << endl;
cout << "SumMinutes: " << d3.getTime().MinutesVal << endl;
cout << "SumSeconds: " << d3.getTime().SecondsVal << endl;
cout << "Total_Time  " << "Days: " << d3.totalTime().sumDays << ", Hours: "  << d3.totalTime().sumHours << ", Minutes: " << d3.totalTime().sumMinutes << ", Seconds: " << d3.totalTime().sumSeconds << endl;

//cout << "T: " << d1.t  << endl:
return 0;
}
